#tag Class
Protected Class TestTask
Inherits Thread
	#tag Event
		Sub Run()
		  
		  Dim theTaskLink As zdTaskListMessenger = zdTaskListWin.RegisterNewTask("Thread #" + Str(me.ThreadCounter),"Starting", zdTaskListMessenger.TaskPaused)
		  
		  me.ThreadCounter = me.ThreadCounter + 1
		  
		  me.Sleep(App.RndGenerator.InRange(500,1000))
		  
		  Dim theMax As Integer = App.RndGenerator.InRange(500, 3000000)
		  
		  For i as Integer = 0 to theMax
		    
		    theTaskLink.State = "Handling step #" + Str(i\100000)
		    theTaskLink.Progress = (i / theMax)*100
		    
		    If App.RndGenerator.LessThan(1000000) = 7669 then
		      
		      theTaskLink.Progress = zdTaskListMessenger.TaskPaused
		      theTaskLink.State = "Sleeping for a while..."
		      me.Sleep(App.RndGenerator.InRange(100,3000))
		      theTaskLink.State = "Handling step #" + Str(i\100000)
		      theTaskLink.Progress = (i / theMax)*100
		      
		    End If
		    
		  Next
		  
		  theTaskLink = Nil
		End Sub
	#tag EndEvent


	#tag Property, Flags = &h0
		Shared ThreadCounter As Integer
	#tag EndProperty


	#tag ViewBehavior
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Priority"
			Visible=true
			Group="Behavior"
			InitialValue="5"
			Type="Integer"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="StackSize"
			Visible=true
			Group="Behavior"
			InitialValue="0"
			Type="Integer"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Thread"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InheritedFrom="Thread"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
